package com.iflytek.universitymanagement.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iflytek.universitymanagement.domain.LearningPlan;
import com.iflytek.universitymanagement.mapper.LearningPlanMapper;
import com.iflytek.universitymanagement.service.LearningPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LearningPlanServiceImpl extends ServiceImpl<LearningPlanMapper, LearningPlan> implements LearningPlanService {
    @Autowired
    private LearningPlanMapper learningPlanMapper;

//    @Override
//    public LearningPlan getLearningPlanByStudentId(Integer studentId) {
//        return baseMapper.selectOne(new QueryWrapper<LearningPlan>().eq("student_id", studentId));
//    }

    @Override
    public void saveLearningPlan(LearningPlan learningPlan) {
        // 保存学习计划到数据库
        learningPlanMapper.insert(learningPlan);
    }

    @Override
    public List<LearningPlan> getLearningPlansByStudentIdAndSubject(Integer studentId, String subject) {
        return this.baseMapper.selectLearningPlansByStudentIdAndSubject(studentId, subject);
    }

    @Override
    public boolean deleteLearningPlansByStudentIdAndSubject(Integer studentId, String subject) {
        return this.baseMapper.deleteLearningPlansByStudentIdAndSubject(studentId, subject) > 0;
    }
}